{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Short-Circuit Calculation Considering Renewable Energy Resources\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the 2016 revision of the standard, the contribution of full converter elements like wind parks of photovoltaic or wind power plants, which was previously neglected, has been integrated.  \n",
    "\n",
    "In the paper [Short Circuit Calculation with Fullsize Converters According to IEC 60909](https://www.researchgate.net/publication/309430459_SHORT-CIRCUIT_CALCULATION_WITH_FULLSIZE_CONVERTERS_ACCORDING_TO_IEC_60909), the process is explained and an example is given. This example is used here to validate the correct implementation of the 2016 revision of the standard in pandapower."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example Network\n",
    "\n",
    "The following network is introduced as example in the paper:\n",
    "    \n",
    "<img src=\"shortcircuit/example_renewables.png\" width=\"50%\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This network can be modeled in pandapower with the line parameters given in the paper as:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:28:52.384350Z",
     "start_time": "2025-10-17T08:28:47.885925Z"
    }
   },
   "outputs": [],
   "source": [
    "from pandapower.create import (\n",
    "    create_empty_network,\n",
    "    create_bus,\n",
    "    create_ext_grid,\n",
    "    create_line,\n",
    "    create_sgen\n",
    ")\n",
    "from pandapower.shortcircuit import calc_sc\n",
    "from pandapower.std_types import create_std_type\n",
    "import numpy as np\n",
    "\n",
    "net = create_empty_network()\n",
    "for i in range(4):\n",
    "    create_bus(net, vn_kv=110., index=i+1)\n",
    "    \n",
    "create_ext_grid(net, 1, s_sc_max_mva=20*110*np.sqrt(3), rx_max=0.1)\n",
    "create_std_type(net, {\"r_ohm_per_km\": 0.120, \"x_ohm_per_km\": 0.393, \"c_nf_per_km\": 0.19,\n",
    "                         \"max_i_ka\": 0.6}, \"example_type\")\n",
    "\n",
    "for fb, tb, length in [(1, 2, 100), (1, 3, 50), (2, 3, 50), (3, 4, 25)]:\n",
    "    create_line(net, from_bus=fb, to_bus=tb, length_km=length, std_type=\"example_type\")\n",
    "\n",
    "for b, p in [(2, 100), (3, 50), (4, 50)]:\n",
    "    create_sgen(net, b, p_mw=p, sn_mva=p, k=1.2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Short Circuits Without Windparks\n",
    "\n",
    "First, we disable the static generators that represent the wind parks and run a short circuit calculation without the wind park contribution:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:28:54.541042Z",
     "start_time": "2025-10-17T08:28:52.391873Z"
    }
   },
   "outputs": [],
   "source": [
    "net.sgen.in_service = False\n",
    "calc_sc(net, ip=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The result given in the paper without wind park contribution for a fault at bus 2 is Ikss = 2.9133 kA and ip = 5.9746 kA. Checking the results table shows that pandapower gives the same results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:28:54.569144Z",
     "start_time": "2025-10-17T08:28:54.548538Z"
    }
   },
   "outputs": [],
   "source": [
    "net.res_bus_sc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Minor deviations in the results can be explained since the values in the paper are obtained from rounded intermediate results in the paper."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Short Circuits With Windparks\n",
    "\n",
    "We now activate the three wind parks and run the short circuit calculation again:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:28:55.049094Z",
     "start_time": "2025-10-17T08:28:55.011101Z"
    }
   },
   "outputs": [],
   "source": [
    "net.sgen.in_service = True\n",
    "calc_sc(net, ip=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The result given in the paper with wind park contribution for a fault at bus 2 is Ikss = 3.9034 kA and ip = 7.3746 kA. Checking the results table shows that pandapower results yields the same result:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-17T08:28:55.174278Z",
     "start_time": "2025-10-17T08:28:55.145146Z"
    }
   },
   "outputs": [],
   "source": [
    "net.res_bus_sc"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
